﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using UCS.ArtificialInteligence.MiniMax;

namespace UCS.XNA.Draughts.AI
{
    public class ComputerMoveCalculation
    {
        #region Attributes and Properties

        private bool _isFinished = false;
        public bool IsFinished
        {
            get { return _isFinished; }
        }

        private BoardState _result;
        public BoardState Result
        {
            get { return _result; }
        }

        #endregion

        #region Private Members

        private BoardState _currentState;
        private Thread _thread;

        #endregion

        #region Constructors

        public ComputerMoveCalculation(BoardState currentState)
        {
            _currentState = currentState;
            _thread = new Thread(CalculateResult);
        }

        public void Start()
        {
            _thread.Start();
        }

        #endregion

        #region Private Methods

        private void CalculateResult()
        {
            DateTime before = DateTime.Now;
            _result = new MiniMaxSearch(5, true).GetNextMovement(_currentState) as BoardState;
            DateTime after = DateTime.Now;

            Console.WriteLine(after - before);

            //_isFinished = true;
        }

        #endregion
    }
}
